<template>
  <j-modal
    switchFullscreen
    :title='title'
    :width='900'
    :visible='visible'
    :maskClosable='false'
    :confirmLoading='confirmLoading'
    @ok='handleOk'
    @cancel='handleCancel'
    cancelText='关闭'>
    <template slot="footer">
      <a-button @click="handleCancel">取消</a-button>
      <a-button @click="handleOk" type="primary" v-if="!disableSubmit">确认</a-button>
    </template>
    <a-spin :spinning='confirmLoading'>
      <a-form :form='form'>
        <a-row :gutter='24'>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='客户编号'
            >
              <a-input  :disabled='true' v-decorator="['customerCode']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='客户名称'
            >
              <a-input  :disabled='true' v-decorator="['customerName']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='组织编号'
            >
              <a-input  :disabled='true' v-decorator="['orgCode']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='组织名称'
            >
              <a-input  :disabled='true' v-decorator="['orgName']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='问题类别'
            >
              <cn-dict-select-tag
                dict-code="feedback_type"
                triggerChange
                :disabled="true"
                :options="{value:'dictDataCode',label:'dictDataDesc'}"
                v-decorator.trim="['problemType',{initialValue:'1'}]"/>
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='订单编号'
            >
              <a-input  :disabled='true' v-decorator="['orderCode']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='负责人编号'
            >
              <a-input  :disabled='true' v-decorator="['userCode']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='客户负责人'
            >
              <a-input  :disabled='true' v-decorator="['userName']" />
            </a-form-item>
          </a-col>
          <a-col :md='8' :sm='24'>
            <a-form-item
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              label='提交时间'
            >
              <a-input  :disabled='true' v-decorator="['createTime']" />
            </a-form-item>
          </a-col>
          <a-col :md='24' :sm='24'>
            <a-form-item
              :labelCol="{ xs: { span:24 }, sm: { span: 2}}"
              :wrapperCol="{ xs: { span:24 }, sm: { span: 22}}"
              style="margin-left: 10px"
              label="问题详情">
              <a-textarea  :disabled='true' v-decorator="['questionDetails']" style="height: 150px"  />
            </a-form-item>
          </a-col>
          <a-col :md='24' :sm='24'>
            <a-form-item
              :labelCol="{ xs: { span:24 }, sm: { span: 2}}"
              :wrapperCol="{ xs: { span:24 }, sm: { span: 22}}"
              style="margin-left: 10px"
              label="回复信息">
              <a-textarea placeholder="请输入回复" :disabled='disableSubmit' v-decorator="['replyMessage',]" style="height: 150px"/>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>
import proChose from '@comp/cn-components/ProChose'
import { postAction } from '@/api/manage'
import { pick } from 'lodash'
import JTreeSelect from '@/components/cn-form/JTreeSelect'
import JAreaLinkage from '@comp/cn-form/CnAreaLinkage'
import UploadImage from '@/components/upload-image/UploadImage'
import JImageUpload from '@/components/cn-form/JImageUpload'

export default {
  name: 'proMinPriceModal',
  data() {
    return {
      sendPro: false,
      remarks: '',
      dataSurces: [],
      manobjList: [0],
      areaData: '',
      areaLinkage: '',
      title: '操作',
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {
        input: {
          rules: [
            { required: true, message: ''}
          ]
        },
      },
      addOrUpdateUrl: window._CONFIG['domianDmsURL'] + '/customerfeedback/DmsCustomerFeedback/saveOrUpdate'
    }
  },
  components: { JTreeSelect, JAreaLinkage, UploadImage, JImageUpload,proChose },
  created() {
  },
  methods: {
    add() {
      this.edit()
    },
    edit(record) {
      this.form.resetFields()
      this.model = Object.assign({}, record)
      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, Object.keys(this.model)))//表单初始化，值源于this.model
      })
    },
    handleCancel() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      let that = this
      this.form.validateFields((err, value) => {
        if (!err) {
          let obj = Object.assign({}, this.model, value)
          obj.status=2
          postAction(this.addOrUpdateUrl, obj).then(res => {
            if (res.success) {
              that.$message.success(res.message, 2)
              that.$emit('ok')
              that.handleCancel()
            } else {
              that.$message.error(res.message, 2)
            }
          }).finally(() => {
            that.confirmLoading = false
          })
        }
      })
    }

  }
}
</script>

<style lang='less' scoped>
.info-line {
  display: flex;
  flex-direction: row;
}

.info-line:before {
  content: "";
  flex: 0.1;
  border-bottom: 1px solid #ebedee;
  margin: auto 4px;
}
.info-line:after {
  content: "";
  flex: 0.9;
  border-bottom: 2px solid #ebedee;
  margin: auto 4px;
}
</style>
